#include <common.h>
void do_syscall(Context *c);
static Context* do_event(Event e, Context* c) {
  switch (e.event) {
		case EVENT_SYSCALL: do_syscall(c);c->mepc +=4;break;
#ifdef TIMER_IRQ
		case EVENT_IRQ_TIMER: {static int times = 0;times ++;printf("TIMER_IRQ %d times\n",times);*(uint64_t*)(0x200BFF8) = 0;break;}
#endif
#ifdef SOFT_IRQ
		case EVENT_IRQ_SOFT: {*(uint64_t*)(0x2000000) = 0;printf("soft intr happened \n"); break;}
#endif
    default: panic("Unhandled event ID = %d", e.event);
  }

  return c;
}

void init_irq(void) {
  Log("Initializing interrupt/exception handler...");
  cte_init(do_event);
}
